extends Node

# 此脚本用于创建简单的占位符素材，用于游戏原型开发
# 运行此脚本将在assets文件夹中生成基本的占位符图像

func _ready():
	print("开始创建占位符素材...")
	
	# 创建幻兽占位符
	create_monster_placeholders()
	
	# 创建环境占位符
	create_environment_placeholders()
	
	# 创建UI占位符
	create_ui_placeholders()
	
	# 创建图标
	create_icon()
	
	print("占位符素材创建完成！")

# 创建幻兽占位符
func create_monster_placeholders():
	# 创建普通幻兽占位符
	create_colored_rect(32, 32, Color(0.2, 0.8, 0.2), "res://assets/characters/monsters/common/fire_slime.png")
	create_colored_rect(32, 32, Color(0.2, 0.2, 0.8), "res://assets/characters/monsters/common/water_blob.png")
	
	# 创建稀有幻兽占位符
	create_colored_rect(48, 48, Color(0.8, 0.8, 0.2), "res://assets/characters/monsters/rare/wind_falcon.png")
	create_colored_rect(48, 48, Color(0.6, 0.4, 0.2), "res://assets/characters/monsters/rare/rock_golem.png")
	
	# 创建史诗幻兽占位符
	create_colored_rect(64, 64, Color(1.0, 1.0, 0.6), "res://assets/characters/monsters/epic/light_unicorn.png")
	create_colored_rect(64, 64, Color(0.4, 0.0, 0.4), "res://assets/characters/monsters/epic/shadow_wolf.png")
	
	# 创建传说幻兽占位符
	create_colored_rect(80, 80, Color(1.0, 0.4, 0.0), "res://assets/characters/monsters/legendary/ancient_dragon.png")

# 创建环境占位符
func create_environment_placeholders():
	# 创建森林环境占位符
	create_colored_rect(128, 128, Color(0.0, 0.5, 0.0), "res://assets/environments/forest/forest_background.png")
	create_colored_rect(32, 32, Color(0.0, 0.3, 0.0), "res://assets/environments/forest/forest_tile.png")
	create_colored_rect(32, 64, Color(0.4, 0.3, 0.1), "res://assets/environments/forest/tree.png")
	
	# 创建草原环境占位符
	create_colored_rect(128, 128, Color(0.5, 0.8, 0.2), "res://assets/environments/grassland/grassland_background.png")
	create_colored_rect(32, 32, Color(0.4, 0.7, 0.1), "res://assets/environments/grassland/grass_tile.png")
	
	# 创建沙漠环境占位符
	create_colored_rect(128, 128, Color(0.9, 0.8, 0.5), "res://assets/environments/desert/desert_background.png")
	create_colored_rect(32, 32, Color(0.8, 0.7, 0.4), "res://assets/environments/desert/sand_tile.png")
	
	# 创建雪山环境占位符
	create_colored_rect(128, 128, Color(0.9, 0.9, 1.0), "res://assets/environments/snow/snow_background.png")
	create_colored_rect(32, 32, Color(0.8, 0.8, 0.9), "res://assets/environments/snow/snow_tile.png")
	
	# 创建地下洞穴环境占位符
	create_colored_rect(128, 128, Color(0.3, 0.3, 0.3), "res://assets/environments/cave/cave_background.png")
	create_colored_rect(32, 32, Color(0.2, 0.2, 0.2), "res://assets/environments/cave/cave_tile.png")

# 创建UI占位符
func create_ui_placeholders():
	# 创建按钮占位符
	create_colored_rect(100, 40, Color(0.2, 0.4, 0.8), "res://assets/ui/battle/button_normal.png")
	create_colored_rect(100, 40, Color(0.3, 0.5, 0.9), "res://assets/ui/battle/button_hover.png")
	create_colored_rect(100, 40, Color(0.1, 0.3, 0.7), "res://assets/ui/battle/button_pressed.png")
	
	# 创建面板占位符
	create_colored_rect(300, 200, Color(0.2, 0.2, 0.2, 0.8), "res://assets/ui/battle/panel_background.png")
	create_colored_rect(300, 200, Color(0.3, 0.3, 0.3, 0.8), "res://assets/ui/inventory/inventory_panel.png")
	
	# 创建血条占位符
	create_colored_rect(100, 10, Color(0.8, 0.2, 0.2), "res://assets/ui/battle/health_bar.png")
	create_colored_rect(100, 10, Color(0.2, 0.8, 0.2), "res://assets/ui/battle/mana_bar.png")

# 创建图标
func create_icon():
	var image = Image.new()
	image.create(64, 64, false, Image.FORMAT_RGBA8)
	
	# 填充颜色
	for x in range(64):
		for y in range(64):
			var distance = sqrt(pow(x - 32, 2) + pow(y - 32, 2))
			if distance < 30:
				var color = Color(0.8, 0.4, 0.0)  # 橙色
				image.set_pixel(x, y, color)
			else:
				image.set_pixel(x, y, Color(0, 0, 0, 0))  # 透明
	
	# 保存图像
	image.save_png("res://icon.png")
	print("创建图标: res://icon.png")

# 创建彩色矩形图像
func create_colored_rect(width, height, color, path):
	var image = Image.new()
	image.create(width, height, false, Image.FORMAT_RGBA8)
	
	# 填充颜色
	for x in range(width):
		for y in range(height):
			image.set_pixel(x, y, color)
	
	# 添加边框
	for x in range(width):
		image.set_pixel(x, 0, Color.BLACK)
		image.set_pixel(x, height - 1, Color.BLACK)
	
	for y in range(height):
		image.set_pixel(0, y, Color.BLACK)
		image.set_pixel(width - 1, y, Color.BLACK)
	
	# 确保目录存在
	var dir = Directory.new()
	var dir_path = path.get_base_dir()
	
	if not dir.dir_exists(dir_path):
		dir.make_dir_recursive(dir_path)
	
	# 保存图像
	image.save_png(path)
	print("创建占位符图像: " + path)
